#include "filepropertyinfo.h"
#include "ui_filepropertyinfo.h"

FilePropertyInfo::FilePropertyInfo(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::FilePropertyInfo)
{
    ui->setupUi(this);
}

FilePropertyInfo::~FilePropertyInfo()
{
    delete ui;
}

void FilePropertyInfo::setInfo(FileInfo *info)
{
    ui->filename->setText(info->filename);
    ui->uploader->setText(info->user);
    ui->upload_time->setText(info->createTime);

    int size = info->size;
    if(size <= 1024*1024)
    {
        ui->file_size->setText(QString("%1 KB").arg(size/1024.0));
    }
    else
    {
        ui->file_size->setText(QString("%1 MB").arg(size/1024.0/1024.0));
    }

    ui->pv->setText(QString("被下载 %1 次").arg(info->pv));
    if(info->shareStatus == 0)
    {
        ui->shared_state->setText("未分享");
    }
    else
    {
        ui->shared_state->setText("已分享");
    }

    QString tmp = QString("<a href=\"%1\">%2</a>").arg(info->url).arg(info->url);
    ui->download_address->setText(tmp);
}
